local p = {}
-- 通用
local getArgs = require('Module:Arguments').getArgs
 
function p.main(frame)
	local args = getArgs(frame)
	local text = '<span class="inline-skill-name" style="display:inline-block">'
	local type ='主动'
	local icon = args.icon or args.i or ''
	local show_i = true
	local display_desc = false
	local name
	
	-- 生成图标	
	if (args.icon or '') ~= '' then	
		icon = '[[File:Skill_'..args.icon..'.png|22px|link=]]'
	end
	
	if ((args.p or '') ~= '') or ((args.icon or '') == '') then			-- 新方式
		--SMW读取
		local page = 'Char/'..(tonumber(mw.text.split(args.page, '/')[2]) or tonumber(args.page))
		local num = args.i or args[1]
		if tonumber(num) ~= nil then
			num = '共鸣术'..num
		end
		
		local num_s = num
		if (num == '调律')then
			num_s = '调律爆发0'
		end
		if (num == '固有')then
			num_s = '固有技能0'
		end
		local tab = mw.smw.getQueryResult('[['..page..'#'..num_s..']]|?Name|?Desc|?图标|?主角技能类型')
	
		local result = tab["results"][1]["printouts"]
		local name = args.name or result['Name'][1] or ''
		local desc = result['Desc'][1] or ''
		name = args.name or args.n or result['Name'][1] or ''
		icon = result['图标'][1] or ''
		local category = result['主角技能类型'][1] or ''
		
        if (tonumber(num) or '' ~= '') then
		    text = text..'<span class="label-item label-color-normal">技能'..(num + 1)..'</span>' --临时
        else
		    text = text..'<span class="label-item label-color-normal">'..num..'</span>' --临时
        end
		if icon ~= '' then
			text = text..'[[File:'..icon..'|22px|link=]]'
		else
			return '【错误】无法获取技能图标'
		end
	
		if (desc ~= '') and display_desc then
			text = text..'<span class="tooltips">[['..page..'#'..num_s..'|'..name..']]<span norecord_s></span><div class="tooltips-content nowrap" style="text-align:left;">'..desc..'</div><span norecord_e></span></span>'
		else
			--text = text..'[['..page..'#'..num_s..'|'..name..']]'
			text = text..name
		end
		text = text..'</span>'
	else			-- 旧方式
		if (args.i or '') ~= '' then
			if tonumber(args.i) ~= nil then			-- 生成Label
				text = text..'<span class="label-item">技能'..args.i..'</span>'
			else
				text = text..'<span class="label-item">'..args.i..'</span>'
			end
		end
	
		text = text..icon
		if args.link then
			name = '[['..args.link..'|'..args.name..']]'
		else
			name = args.name
		end
		if args.desc then
			text= text..'<span class="tooltips">'..name.. '<span norecord_s></span><span class="tooltips-content nowrap" style="text-align:left">'..args.desc..'</span><span norecord_e></span></span>'
		elseif args.name_jp then
			text= text..'<span class="tooltips">'..name.. '<span class="tooltips-content nowrap">'..args.name..'</span></span>'
		else
			text = text..name
		end
		text = text..'</span>'
	end
	
	return text
end
 
return p
